home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The 640 MEG Shareware Studio 2
/
The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO
/
pascal
/
tpb4_src.zip
/
INITIAL1.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1988-09-13
|
9KB
|
313 lines
{ TPBoard 4.2 Copyright (c) 1987,88 by Jon Schneider & Rick Petersen
Portions Copyright (c) 1986,87 by Steve Fox and Les Archambault
Last modified :: 6-15-88 11:35 pm
}
{$R-} {Range checking off}
{$B-} {Boolean complete evaluation off}
{$S-} {Stack checking off}
{$I+} {I/O checking on}
{$N-} {No numeric coprocessor}
Unit Initial1;
Interface
Uses
TPCrt, Dos, Globals, TPSTRING,
TPDOS, Core1, Core2, Initial3;
procedure cold_start;
{==========================================================================}
Implementation
procedure cold_start;
var
i, try, errcnt : Integer;
sysm_text : Text;
t : tad_array;
procedure fansi;
{
Make sure use reset, as rewrite will create a file
called FCON on the disk if Fansi is not here.
}
begin
Assign(Lst, 'fcon');
{$I-}
Reset(Lst);
{$I+}
if IoResult = 0 then
begin
fconsole := True;
Close(Lst);
end
else
fconsole := False;
end { fansi } ;
procedure open_quote_file;
{ builds QUOTES.BB# and QUOTEIDX.BB# if necessary, and opens them }
var
rec_count : Integer;
in_quote : Boolean;
qtxt_file : Text; {file var for QUOTES.TXT}
quot_exists : Boolean;
qtxt_exists : Boolean;
begin {procedure open_quote_file}
Randomize;
quot_exists := ExistFile(quot_name+ext) and ExistFile(qidx_name+ext);
qtxt_exists := ExistFile(quot_name+'.TXT');
if not quot_exists then
begin
{rebuild QUOTES.BB# and QUOTEIDX.BB# from QUOTES.TXT}
if qtxt_exists then
begin
WriteLn(Char(BEL)+quot_name+ext+' and/or '+qidx_name+ext+' not found.');
WriteLn('Rebuilding '+quot_name+ext+' and '+qidx_name+ext+'.');
Assign(quot_file, quot_name+ext);
Rewrite(quot_file);
Assign(qidx_file, qidx_name+ext);
Rewrite(qidx_file);
Assign(qtxt_file, quot_name+'.TXT');
Reset(qtxt_file);
rec_count := 0;
in_quote := False;
while not EoF(qtxt_file) do
begin
ReadLn(qtxt_file, quot_rec.Text);
quot_rec.Text := trim(quot_rec.Text);
if (not in_quote) and (quot_rec.Text <> '') then
begin
in_quote := True;
qidx_rec.loc := rec_count;
Write(qidx_file, qidx_rec);
end;
if in_quote then
begin
Write(quot_file, quot_rec);
Inc(rec_count);
in_quote := quot_rec.Text <> '';
end;
end;
Close(qtxt_file);
Close(quot_file);
Close(qidx_file);
end;
end;
if quot_exists or qtxt_exists then
begin
Assign(quot_file, quot_name+ext);
Reset(quot_file);
Assign(qidx_file, qidx_name+ext);
Reset(qidx_file);
quot_count := FileSize(qidx_file);
end
else
quot_count := 0;
end; {procedure open_quote_file}
procedure build_sysm;
{ Build SYSMSG.BB# file }
var
i : Integer;
goof, Error : Boolean;
work : string[80];
begin
goof := False;
errcnt := 0;
{$I-}
Close(sysm_file) {$I+} ; { Shouldn't erase an open file }
i := IoResult; { Ignore any errors }
Rewrite(sysm_file);
Assign(sysm_text, current_name+'.TXT');
{$I-}
Reset(sysm_text) {$I+} ;
if IoResult = 0 then
begin
Write(' Creating ', current_name, ext);
while (not EoF(sysm_text)) and (errcnt < 50) do
begin
{$I-}
ReadLn(sysm_text, work); {$I+}
Error := (IoResult <> 0);
if Length(work) > 79 then
begin
sysm_rec := Copy(work, 1, 79);
WriteLn;
WriteLn;
WriteLn('Line too long, truncating.');
WriteLn;
goof := True;
end
else
sysm_rec := work;
if not Error then
Write(sysm_file, sysm_rec);
if Error then
begin
WriteLn;
WriteLn;
WriteLn('Error reading text line. No CR,LF ? ');
goof := True;
Inc(errcnt);
end;
end; {while not eof text file}
Close(sysm_text);
Close(sysm_file);
Reset(sysm_file);
if goof or Error then
begin
WriteLn;
WriteLn(current_name,
'TXT problem may result in parts of SYSMSG.BB# not being complete.');
WriteLn;
WriteLn(' Lines in text file should not be longer than 79 characters');
WriteLn(' or have high bits set (soft CRs) by the editor you use.');
WriteLn;
Delay(10000);
end;
end {ioresult=0}
else
begin
WriteLn;
Write('System message text file ', current_name, 'TXT not found.');
end;
WriteLn;
end;
procedure Open_system_message;
var
OK : Boolean;
begin
try := 0;
{$I-}
Reset(sysm_file) {$I+} ; { Try to open system message file }
if IoResult <> 0 then
begin
Write('Cannot open ', current_name+ext, '.');
build_sysm;
Inc(try);
end;
{$I-}
Read(sysm_file, sysm_rec) {$I+} ; { Try to read file }
if IoResult <> 0 then
begin
OK := False;
if try = 0 then
begin
Write('Cannot read ', current_name+ext, '.');
build_sysm;
Seek(sysm_file, 0);
{$I-}
Read(sysm_file, sysm_rec); {$I+}
OK := (IoResult = 0);
end;
if not OK then
begin
WriteLn;
WriteLn('Cannot create ', current_name+ext, '.');
WriteLn('Unable to continue.');
Halt;
end;
end;
i := 0;
end;
begin {cold start}
CheckBreak := False;
cold := True;
mult_cmds := False; {no multiple commands}
Cmd_Queue := '';
if ExistFile('TPBUP.BB#') then
begin
WriteLn('TPBoard may already be resident, use ''EXIT'' to return.');
WriteLn('If that doesn''t work, erase the file ''TPBUP.BB#''.');
Halt
end
else
begin
Assign(temp_file, 'TPBUP.BB#');
Rewrite(temp_file);
Close(temp_file);
end;
macro_in_progress := False;
GetTAD(t);
macro_done := t[3];
audit_on := False;
delay_down := False;
in_library := False; { Start in non-library mode }
in_arc := False;
Queue := '';
SysmBase := nil; { Initialize pointers}
SectBase := nil;
AreaBase := nil;
MesgBase := nil;
DirBase := nil;
LibBase := nil;
Artbase := nil;
ArcBase := nil;
NetAreaBase := nil;
ExitSave := ExitProc;
ExitProc := @NewExit;
AssignAux(Com); { Initialize output driver }
Rewrite(Com);
fansi;
GetDir(0, HomName);
HomDrv := Copy(HomName, 1, 3); { Assume system files are here }
AudName := HomName;
AudDrv := Copy(AudName, 1, 3); { default setting}
RcvName := HomName;
RcvDrv := Copy(RcvName, 1, 3);
Assign(summ_file, summ_name+ext);
Assign(mesg_file, mesg_name+ext);
Assign(logr_file, logr_name+ext);
Assign(nwin_file, nwin_name+ext);
Assign(sysm_file, sysm_name+ext);
current_name := sysm_name; { Open ASCII system message file }
Open_system_message;
Close(sysm_file);
Assign(sysm_file, sysmg_name+ext); { Open ANSI system message file }
current_name := sysmg_name;
Open_system_message;
ReadConfigFile;
ReadOrigFile;
ReadSectionFile;
open_quote_file;
if auto_macro and (t[2] < auto_macro_start) then
macro_done := t[3]-1;
end;
end. { of INITIAL1.PAS }